//
//  PCFindManager.m
//  PromotionCode
//
//  Created by uuu9 on 2017/12/17.
//  Copyright © 2017年 My. All rights reserved.
//

#import "PCFindManager.h"
#import "PCFindModel.h"
#import "PCFreeBuyListModel.h"
#import "PCGoodsModel.h"
#import "U9CatagoryModel.h"


@implementation PCFindManager

+ (void)getFindListWithCompletionHandle:(void (^)(PCFindModel *, NSError *))complete{
    [self POST:[NSString stringWithFormat:@"%@%@",Api_URL,kFind]
   parameters:nil
completionHandler:^(id responseObj, NSError *error) {
    PCFindModel *model = [PCFindModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model,error);
}];
}


+ (void)getFreeBuyListWithPageNum:(NSString *)pageNum andChannel:(NSString *)channelID andOrder:(NSString *)order andCompletionHandle:(void (^)(PCFreeBuyListModel *, NSError *))complete{
    [self GET:[NSString stringWithFormat:@"%@%@?p=%@&class=%@&order=%@",Api_URL,kFreeBuyList,pageNum,channelID,order]
   parameters:nil
completionHandler:^(id responseObj, NSError *error) {
    PCFreeBuyListModel *model = [PCFreeBuyListModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model,error);
}];
}

+ (void)getGoodsDetailWithGoodsID:(NSString *)goodsID andCompletionHandle:(void (^)(PCGoodsModel *, NSError *))complete{
    [self GET:[NSString stringWithFormat:@"%@%@?id=%@",Api_URL,kGoodsDetail,goodsID]
   parameters:nil
completionHandler:^(id responseObj, NSError *error) {
    PCGoodsModel *model = [PCGoodsModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model,error);
}];
}

+ (void)getChannelWithCompletionHandle:(void (^)(U9CatagoryModel *, NSError *))complete{
    [self GET:[NSString stringWithFormat:@"%@%@",Api_URL,kFreeBuyChannel]
   parameters:nil
completionHandler:^(id responseObj, NSError *error) {
    U9CatagoryModel *model = [U9CatagoryModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model,error);
}];
}



@end
